Search Results

Search found 11996 results on 480 pages for 'dependency properties'.

Page 8/480 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How to read a Dependency property from a method

    - by PaN1C_Showt1Me
    XAML: <my:Control ItemsSource="{StaticResource MySource}" A="true" /> Assume a Control with a dependency property A with a default value false; and a method to handle the Source Collection: protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue) {} in which you want to look at A and readout its value (which is true). how would you ensure, that A is already initialized and has a given value? Or how should this be done correctly ? In my case A is something like AllowLateBinding .. Could coerce callback help me?

    Read the article

  • Resolve circular typedef dependency?

    - by Nick
    What is the best way to resolve the following circular dependency in typedef-ing these structs? Note the C language tag - I'm looking for a solution in standard gcc C. typedef struct { char* name; int age; int lefthanded; People* friends; } Person; typedef struct { int count; int max; Person* data; } People;

    Read the article

  • How to make Delphi Prism indexed properties visible to C# when properties are not default

    - by Arcturus
    I have several Delphi Prism classes with indexed properties that I use a lot on my C# web applications (we are migrating a big Delphi Win32 system to ASP.Net). My problem is that it seems that C# can't see the indexed properties if they aren't the default properties of their classes. Maybe I'm doing something wrong, but I'm completely lost. I know that this question looks a lot like a bug report, but I need to know if someone else knows how to solve this before I report a bug. If I have a class like this: TMyClass = public class private ... method get_IndexedBool(index: Integer): boolean; method set_IndexedBool(index: Integer; value: boolean); public property IndexedBool[index: Integer]: boolean read get_IndexedBool write set_IndexedBool; default; // make IndexedBool the default property end; I can use this class in C# like this: var myObj = new TMyClass(); myObj[0] = true; However, if TMyClass is defined like this: TMyClass = public class private ... method get_IndexedBool(index: Integer): boolean; method set_IndexedBool(index: Integer; value: boolean); public property IndexedBool[index: Integer]: boolean read get_IndexedBool write set_IndexedBool; // IndexedBool is not the default property anymore end; Then the IndexedBool property becomes invisible in C#. The only way I can use it is doing this: var myObj = new TMyClass(); myObj.set_IndexedBool(0, true); I don't know if I'm missing something, but I can't see the IndexedBool property if I remove the default in the property declaration. Besides that, I'm pretty sure that it is wrong to have direct access to a private method of a class instance. Any ideas?

    Read the article

  • Factories, or Dependency Injection for object instantiation in WCF, when coding against an interface

    - by Saajid Ismail
    Hi I am writing a client/server application, where the client is a Windows Forms app, and the server is a WCF service hosted in a Windows Service. Note that I control both sides of the application. I am trying to implement the practice of coding against an interface: i.e. I have a Shared assembly which is referenced by the client application. This project contains my WCF ServiceContracts and interfaces which will be exposed to clients. I am trying to only expose interfaces to the clients, so that they are only dependant on a contract, not any specific implementation. One of the reasons for doing this is so that I can have my service implementation, and domain change at any time without having to recompile and redeploy the clients. The interfaces/contracts will in this case not change. I only need to recompile and redeploy my WCF service. The design issue I am facing now, is: on the client, how do I create new instances of objects, e.g. ICustomer, if the client doesn't know about the Customer concrete implementation? I need to create a new customer to be saved to the DB. Do I use dependency injection, or a Factory class to instantiate new objects, or should I just allow the client to create new instances of concrete implementations? I am not doing TDD, and I will typically only have one implementation of ICustomer or any other exposed interface.

    Read the article

  • Correctly use dependency injection

    - by Rune
    Me and two other colleagues are trying to understand how to best design a program. For example, I have an interface ISoda and multiple classes that implement that interface like Coke, Pepsi, DrPepper, etc.... My colleague is saying that it's best to put these items into a database like a key/value pair. For example: Key | Name -------------------------------------- Coke | my.namespace.Coke, MyAssembly Pepsi | my.namespace.Pepsi, MyAssembly DrPepper | my.namespace.DrPepper, MyAssembly ... then have XML configuration files that map the input to the correct key, query the database for the key, then create the object. I don't have any specific reasons, but I just feel that this is a bad design, but I don't know what to say or how to correctly argue against it. My second colleague is suggesting that we micro-manage each of these classes. So basically the input would go through a switch statement, something similiar to this: ISoda soda; switch (input) { case "Coke": soda = new Coke(); break; case "Pepsi": soda = new Pepsi(); break; case "DrPepper": soda = new DrPepper(); break; } This seems a little better to me, but I still think there is a better way to do it. I've been reading up on IoC containers the last few days and it seems like a good solution. However, I'm still very new to dependency injection and IoC containers, so I don't know how to correctly argue for it. Or maybe I'm the wrong one and there's a better way to do it? If so, can someone suggest a better method? What kind of arguments can I bring to the table to convince my colleagues to try another method? What are the pros/cons? Why should we do it one way? Unfortunately, my colleagues are very resistant to change so I'm trying to figure out how I can convince them.

    Read the article

  • Why can't I Bind a viewmodel property to a dependency property of a custom control

    - by Robert
    I want to use a color picker in my wpf application and I saw a nice looking one on this codeproject page. The control works fine until I want to connect the control to a viewmodel. I created a small test program with this viewmodel: public class ColorViewModel : ViewModelBase { public ColorViewModel() { LineColor = Brushes.Yellow; } SolidColorBrush _brushColor; public SolidColorBrush LineColor { get { return _brushColor; } set { _brushColor = value; RaisePropertyChanged(() => LineColor); } } } The test program has a textbox and the colorpicker controls: <StackPanel Orientation="Horizontal"> <TextBlock Text="Please Select a Color" FontWeight="Bold" Margin="10" Foreground="{Binding Path=LineColor, UpdateSourceTrigger=PropertyChanged}"/> <vw:ColorPickerControlView x:Name="ForeColorPicker" Margin="10" CurrentColor="{Binding Path=LineColor, UpdateSourceTrigger=PropertyChanged }"/> </StackPanel> In the loaded event of the window I set the viewmodel to the datacontext like this: DataContext = new ColorViewModel(); The problem is that I can't seem to bind the LineColor property of the viewmodel to the CurrentColor property of the ColorPickerControlView. The CurrentControl property of the ColorPickerControlView seems to be fine. The constructor looks like this: public ColorPickerControlView() { this.DataContext = this; InitializeComponent(); CommandBindings.Add(new CommandBinding(SelectColorCommand, SelectColorCommandExecute)); } In the constructor of the UserControl there is the line this.DataContext = this; I read that is is necessary to bind the dependency properties. Do I override this line when I set my viewmodel to the datacontext and is that why I can't bind to the CurrentColor property? Is there any workaround? Or did I make another mistake?

    Read the article

  • Dependency Injection for objects that require parameters

    - by Andrew
    All of our reports are created from object graphs that are translated from our domain objects. To enable this, we have a Translator class for each report, and have been using Dependency Injection for passing in dependencies. This worked great, and would yield nice classes structured like this: public class CheckTranslator : ICheckTranslator { public CheckTranslator (IEmployeeService empSvc , IPaycheckService paySvc) { _empSvc = empSvc; _paySvc = paySvc; } public Check CreateCheck() { //do the translation... } } However, in some cases the mapping has many different grouping options. As a result, the c-tor would turn into a mix of class dependencies and parameters. public class CheckTranslator : ICheckTranslator { public CheckTranslator (IEmployeeService empSvc , IPaycheckService paySvc , bool doTranslateStubData , bool doAttachLogo) { _empSvc = empSvc; _paySvc = paySvc; _doTranslateStubData = doTranslateStubData; _doAttachLogo = doAttachLogo; } public Check CreateCheck() { //do the translation... } } Now, we can still test it, but it no longer really works with an IoC container, at least in a clean fashion. Plus, we can no longer call the CreateCheck twice if the settings are different for each check. While I recognize it's a problem, I don't necessarily see the right solution. It seems kind of strange to create a Factory for each class ... or is this the best way?

    Read the article

  • Considerations when architecting an application using Dependency Injection

    - by Dan Bryant
    I've begun experimenting with dependency injection (in particular, MEF) for one of my projects, which has a number of different extensibility points. I'm starting to get a feel for what I can do with MEF, but I'd like to hear from others who have more experience with the technology. A few specific cases: My main use case at the moment is exposing various singleton-like services that my extensions make use of. My Framework assembly exposes service interfaces and my Engine assembly contains concrete implementations. This works well, but I may not want to allow all of my extensions to have access to all of my services. Is there a good way within MEF to limit which particular imports I allow a newly instantiated extension to resolve? This particular application has extension objects that I repeatedly instantiate. I can import multiple types of Controllers and Machines, which are instantiated in different combinations for a Project. I couldn't find a good way to do this with MEF, so I'm doing my own type discovery and instantiation. Is there a good way to do this within MEF or other DI frameworks? I welcome input on any other things to watch out for or surprising capabilities you've discovered that have changed the way you architect.

    Read the article

  • Why does stored procedure invalidate SQL Cache Dependency?

    - by Fabio Milheiro
    After many hours, I finally realize that I am working correctly with the Cache object in my ASP.NET application but my stored procedures stops it from working correctly. This stored procedure works correctly: CREATE PROCEDURE [dbo].[ListLanguages] @Page INT = 1, @ItemsPerPage INT = 10, @OrderBy NVARCHAR (100) = 'ID', @OrderDirection NVARCHAR(4) = 'DESC' AS BEGIN SELECT ID, [Name], Flag, IsDefault FROM dbo.Languages END But this (the one I wanted) doesn't: CREATE PROCEDURE [dbo].[ListLanguages] @Page INT = 1, @ItemsPerPage INT = 10, @OrderBy NVARCHAR (100) = 'ID', @OrderDirection NVARCHAR(4) = 'DESC', @TotalRecords INT OUTPUT AS BEGIN SET @TotalRecords = 10 EXEC('SELECT ID, Name, Flag, IsDefault FROM ( SELECT ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ' ' + @OrderDirection + ') as Row, ID, Name, Flag, IsDefault FROM dbo.Languages) results WHERE Row BETWEEN ((' + @Page + '-1)*' + @ItemsPerPage + '+1) AND (' + @Page + '*' + @ItemsPerPage + ')') END I gave the @TotalRecords parameter the value 10 so you can be sure that the problem is not from the COUNT(*) function which I know is not supported well. Also, when I run it from SQL Server Management Studio, it does exactly what it should do. In the ASP.NET application the results are retrieved correctly, only the cache is somehow unable to work! Can you please help? Maybe a hint I believe that the reason why the dependency HasChanged property is related to the fact that the column Row generated from the ROW_NUMBER is only temporary and, therefore, the SQL SERVER is not able to to say whether the results are changed or not. That's why HasChanged is always set to true. Does anyone know how to paginate results from SQL SERVER without using COUNT or ROW_NUMBER functions?

    Read the article

  • Using maven to distribute a swing application that can have each dependency individually tracked

    - by tms
    I'm moving my project to Maven and eventually OSGi. I currently distribute the project is a large Zip file with all the dependencies. Although my projects code is only 20% of the total package I have to redistribute all the dependency. With smaller independent modules this may be even less. Looking here on stack overflow it seems that to keep my current plan the maven-assembly-plugin should do the trick. I was considering having a base installer that would look at a XML manifest, then collect all the libraries that needed to be updated. This would mean that libraries that change occasionally would be downloaded less often. This also makes since for something like OSGi plugins (which could have independent release schedules). In essence I want my software to look and manage individual libraries, and download on demand (based on the manifest). I was wondering if there is a "maven way" of generating this Manifest and publishing all the libraries to a website? I believe the deploy life-cycle would do the second step. As an alternative, is there a OpenSource Java library that does this type of deployment? I don't want to embed Maven or something larger with the distributed code. The application is not for coders, the simpler the better, and the smaller the installer the better.

    Read the article

  • Dependency Injection into your Singleton

    - by Langali
    I have a singleton that has a spring injected Dao (simplified below): public class MyService<T> implements Service<T> { private final Map<String, T> objects; private static MyService instance; MyDao myDao; public void set MyDao(MyDao myDao) { this. myDao = myDao; } private MyService() { this.objects = Collections.synchronizedMap(new HashMap<String, T>()); // start a background thread that runs for ever } public static synchronized MyService getInstance() { if(instance == null) { instance = new MyService(); } return instance; } public void doSomething() { myDao.persist(objects); } } My spring config will probably look like this: <bean id="service" class="MyService" factory-method="getInstance"/> But this will instantiate the MyService during startup. Is there a programmatic way to do a dependency injection of MyDao into MyService, but not have spring manage the MyService? Basically I want to be able to do this from my code: MyService.getInstance().doSomething(); while having spring inject the MyDao for me.

    Read the article

  • Serializing Configurations for a Dependency Injection / Inversion of Control

    - by Joshua Starner
    I've been researching Dependency Injection and Inversion of Control practices lately in an effort to improve the architecture of our application framework and I can't seem to find a good answer to this question. It's very likely that I have my terminology confused, mixed up, or that I'm just naive to the concept right now, so any links or clarification would be appreciated. Many examples of DI and IoC containers don't illustrate how the container will connect things together when you have a "library" of possible "plugins", or how to "serialize" a given configuration. (From what I've read about MEF, having multiple declarations of [Export] for the same type will not work if your object only requires 1 [Import]). Maybe that's a different pattern or I'm blinded by my current way of thinking. Here's some code for an example reference: public abstract class Engine { } public class FastEngine : Engine { } public class MediumEngine : Engine { } public class SlowEngine : Engine { } public class Car { public Car(Engine e) { engine = e; } private Engine engine; } This post talks about "Fine-grained context" where 2 instances of the same object need different implementations of the "Engine" class: http://stackoverflow.com/questions/2176833/ioc-resolve-vs-constructor-injection Is there a good framework that helps you configure or serialize a configuration to achieve something like this without hard coding it or hand-rolling the code to do this? public class Application { public void Go() { Car c1 = new Car(new FastEngine()); Car c2 = new Car(new SlowEngine()); } } Sample XML: <XML> <Cars> <Car name="c1" engine="FastEngine" /> <Car name="c2" engine="SlowEngine" /> </Cars> </XML>

    Read the article

  • Dependency injection in constructors

    - by andre
    Hello everyone. I'm starting a new project and setting up the base to work on. A few questions have risen and I'll probably be asking quite a few in here, hopefully I'll find some answers. First step is to handle dependencies for objects. I've decided to go with the dependency injection design pattern, to which I'm somewhat new, to handle all of this for the application. When actually coding it I came across a problem. If a class has multiple dependencies and you want to pass on multiple dependencies via the constructor (so that they cannot be changed after you instantiate the object). How do you do it without passing an array of dependencies, using call_user_func_array(), eval() or Reflection? This is what i'm looking for: <?php class DI { public function getClass($classname) { if(!$this->pool[$classname]) { # Load dependencies $deps = $this->loadDependencies($classname); # Here is where the magic should happen $instance = new $classname($dep1, $dep2, $dep3); # Add to pool $this->pool[$classname] = $instance; return $instance; } else { return $this->pool[$classname]; } } } Again, I would like to avoid the most costly methods to call the class. Any other suggestions?

    Read the article

  • Spring Dependency Injecting an annotated Aspect

    Using Spring I've had some issues with doing a dependency injection on an annotated Aspect class. CacheService is injected upon the Spring context's startup, but when the weaving takes place, it says that the cacheService is null. So I am forced to relook up the spring context manually and get the bean from there. Is there another way of going about it? Here is an example of my Aspect: import org.apache.log4j.Logger; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import com.mzgubin.application.cache.CacheService; @Aspect public class CachingAdvice { private static Logger log = Logger.getLogger(CachingAdvice.class); private CacheService cacheService; @Around("execution(public *com.mzgubin.application.callMethod(..)) &&" + "args(params)") public Object addCachingToCreateXMLFromSite(ProceedingJoinPoint pjp, InterestingParams params) throws Throwable { log.debug("Weaving a method call to see if we should return something from the cache or create it from scratch by letting control flow move on"); Object result = null; if (getCacheService().objectExists(params))}{ result = getCacheService().getObject(params); } else { result = pjp.proceed(pjp.getArgs()); getCacheService().storeObject(params, result); } return result; } public CacheService getCacheService(){ return cacheService; } public void setCacheService(CacheService cacheService){ this.cacheService = cacheService; } }

    Read the article

  • Proper structure for dependency injection (using Guice)

    - by David B.
    I would like some suggestions and feedback on the best way to structure dependency injection for a system with the structure described below. I'm using Guice and thus would prefer solutions centered around it's annotation-based declarations, not XML-heavy Spring-style configuration. Consider a set of similar objects, Ball, Box, and Tube, each dependent on a Logger, supplied via the constructor. (This might not be important, but all four classes happen to be singletons --- of the application, not Gang-of-Four, variety.) A ToyChest class is responsible for creating and managing the three shape objects. ToyChest itself is not dependent on Logger, aside from creating the shape objects which are. The ToyChest class is instantiated as an application singleton in a Main class. I'm confused about the best way to construct the shapes in ToyChest. I either (1) need access to a Guice Injector instance already attached to a Module binding Logger to an implementation or (2) need to create a new Injector attached to the right Module. (1) is accomplished by adding an @Inject Injector injectorfield to ToyChest, but this feels weird because ToyChest doesn't actually have any direct dependencies --- only those of the children it instantiates. For (2), I'm not sure how to pass in the appropriate Module. Am I on the right track? Is there a better way to structure this? The answers to this question mention passing in a Provider instead of using the Injector directly, but I'm not sure how that is supposed to work. EDIT: Perhaps a more simple question is: when using Guice, where is the proper place to construct the shapes objects? ToyChest will do some configuration with them, but I suppose they could be constructed elsewhere. ToyChest (as the container managing them), and not Main, just seems to me like the appropriate place to construct them.

    Read the article

  • Global State and Singletons Dependency injection

    - by Manu
    this is a problem i face lot of times when i am designing a new app i'll use a sample problem to explain this think i am writing simple game.so i want to hold a list of players. i have few options.. 1.use a static field in some class private static ArrayList<Player> players = new ArrayList<Integer>(); public Player getPlayer(int i){ return players.get(i); } but this a global state 2.or i can use a singleton class PlayerList{ private PlayerList instance; private PlayerList(){...} public PlayerList getInstance() { if(instance==null){ ... } return instance; } } but this is bad because it's a singleton 3.Dependency injection class Game { private PlayerList playerList; public Game(PlayerList list) { this.list = list; } public PlayerList getPlayerList() { return playerList; } } this seems good but it's not, if any object outside Game need to look at PlayerList (which is the usual case) i have to use one of the above methods to make the Game class available globally. so I just add another layer to the problem. didn't actually solve anything. what is the optimum solution ? (currently i use Singleton approach)

    Read the article

  • Mouse settings/properties dialog box won't open in Windows 7

    - by ymasood
    Hi, I have a problem trying to open my computer's mouse settings by either going to the command prompt and typing, 'control mouse', 'main.cpl' (as researched online) or simply by trying to go to the Control Panel and clicking on 'Mouse' under Hardware and Sound section. I have also tried running cmd as Administrator and trying the above commands but that is of no help. Lastly, if I search for 'mouse' and click 'Mouse' from the Windows search bar, that doesn't work either. In the past I had bought and installed Microsoft Wireless Mobile Mouse 6000 software and have just now bought and installed HP's Wireless Comfort Mobile mouse. Any help in this regard is highly recommended. I won't be able to restore or reinstall my laptop since it's a heavy use machine. Thanks! Yasser

    Read the article

  • Jboss AS 7 - Dependency Injection

    - by Nic Willemse
    Im attempting to make use of dependency injection in Jboss AS 7 and im having huge difficulties. I have setup a EAR which contains both a EJB jar and a war. The war contains a richfaces web app. Im attempting to inject an EJB from the ejb jar into a faces managed bean with the code below : public class UserController { @EJB(mappedName="UserService") private UserFacadeService userService; public String getService(){ if(userService == null){ however when i deploy jboss puts the error in the console : rolled back with failure message {"Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"GoodByeJohnEAR.ear\".\"GoodByeJohnWeb-1.0-SNAPSHOT.war\".component.\"managed-bean.za.co.gbj.UserController\".START missing [ jboss.naming.context.java.module.GoodByeJohnEAR.\"GoodByeJohnWeb-1.0-SNAPSHOT\".\"env/za.co.gbj.UserController/userService\" ]","jboss.deployment.subunit.\"GoodByeJohnEAR.ear\".\"GoodByeJohnWeb-1.0-SNAPSHOT.war\".jndiDependencyService missing [ jboss.naming.context.java.module.GoodByeJohnEAR.\"GoodByeJohnWeb-1.0-SNAPSHOT\".\"env/za.co.gbj.UserController/userService\" ]","jboss.naming.context.java.module.GoodByeJohnEAR.\"GoodByeJohnWeb-1.0-SNAPSHOT\".\"env/za.co.gbj.UserController/userService\".jboss.deployment.subunit.\"GoodByeJohnEAR.ear\".\"GoodByeJohnWeb-1.0-SNAPSHOT.war\".module.GoodByeJohnEAR.\"GoodByeJohnWeb-1.0-SNAPSHOT\".2 missing [ jboss.naming.context.java.module.GoodByeJohnEAR.\"GoodByeJohnWeb-1.0-SNAPSHOT\".env/UserService ]"]} 09:03:50,576 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) Starting deployment of "GoodByeJohnEAR.ear" 09:03:50,670 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "GoodByeJohnWeb-1.0-SNAPSHOT.war" 09:03:50,670 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) Starting deployment of "GoodByeJohnEJB-1.0-SNAPSHOT.jar" 09:03:51,367 WARN [org.jboss.as.server.deployment.service-loader] (MSC service thread 1-2) Encountered invalid class name "com.sun.faces.vendor.Tomcat6InjectionProvider:org.apache.catalina.util.DefaultAnnotationProcessor" for service type "com.sun.faces.spi.injectionprovider" 09:03:51,367 WARN [org.jboss.as.server.deployment.service-loader] (MSC service thread 1-2) Encountered invalid class name "com.sun.faces.vendor.Jetty6InjectionProvider:org.mortbay.jetty.plus.annotation.InjectionCollection" for service type "com.sun.faces.spi.injectionprovider" 09:03:51,375 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named UserFacadeBean in deployment unit subdeployment "GoodByeJohnEJB-1.0-SNAPSHOT.jar" of deployment "GoodByeJohnEAR.ear" are as follows: java:global/GoodByeJohnEAR/GoodByeJohnEJB-1.0-SNAPSHOT/UserFacadeBean!za.co.gbj.UserFacadeService java:app/GoodByeJohnEJB-1.0-SNAPSHOT/UserFacadeBean!za.co.gbj.UserFacadeService java:module/UserFacadeBean!za.co.gbj.UserFacadeService java:global/GoodByeJohnEAR/GoodByeJohnEJB-1.0-SNAPSHOT/UserFacadeBean java:app/GoodByeJohnEJB-1.0-SNAPSHOT/UserFacadeBean java:module/UserFacadeBean 09:03:51,406 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named UserFacadeBean in deployment unit subdeployment "GoodByeJohnWeb-1.0-SNAPSHOT.war" of deployment "GoodByeJohnEAR.ear" are as follows: java:global/GoodByeJohnEAR/GoodByeJohnWeb-1.0-SNAPSHOT/UserFacadeBean!za.co.gbj.UserFacadeService java:app/GoodByeJohnWeb-1.0-SNAPSHOT/UserFacadeBean!za.co.gbj.UserFacadeService java:module/UserFacadeBean!za.co.gbj.UserFacadeService java:global/GoodByeJohnEAR/GoodByeJohnWeb-1.0-SNAPSHOT/UserFacadeBean java:app/GoodByeJohnWeb-1.0-SNAPSHOT/UserFacadeBean java:module/UserFacadeBean 09:03:51,577 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 1) Service status report New missing/unsatisfied dependencies: service jboss.naming.context.java.module.GoodByeJohnEAR."GoodByeJohnWeb-1.0-SNAPSHOT".env/UserService (missing) service jboss.naming.context.java.module.GoodByeJohnEAR."GoodByeJohnWeb-1.0-SNAPSHOT"."env/za.co.gbj.UserController/userService" (missing) Please assist!

    Read the article

  • Dependency Injection: I don't get where to start!

    - by Andy
    I have several articles about Dependency Injection, and I can see the benefits, especially when it comes to unit testing. The units can me loosely coupled, and mocking of dependencies can be made. The trouble is - I just don't get where to start. Consider this snippet below of (much edited for the purpose of this post) code that I have. I am instantiating a Plc object from the main form, and passing in a communications mode via the Connect method. In it's present form it becomes hard to test, because I can't isolate the Plc from the CommsChannel to unit test it. (Can I?) The class depends on using a CommsChannel object, but I am only passing in a mode that is used to create this channel within the Plc itself. To use dependancy injection, I should really pass in an already created CommsChannel (via an 'ICommsChannel' interface perhaps) to the Connect method, or maybe via the Plc constructor. Is that right? But then that would mean creating the CommsChannel in my main form first, and this doesn't seem right either, because it feels like everything will come back to the base layer of the main form, where everything begins. Somehow it feels like I am missing a crucial piece of the puzzle. Where do you start? You have to create an instance of something somewhere, but I'm struggling to understand where that should be. public class Plc() { public bool Connect(CommsMode commsMode) { bool success = false; // Create new comms channel. this._commsChannel = this.GetCommsChannel(commsMode); // Attempt connection success = this._commsChannel.Connect(); return this._connected; } private CommsChannel GetCommsChannel(CommsMode mode) { CommsChannel channel; switch (mode) { case CommsMode.RS232: channel = new SerialCommsChannel( SerialCommsSettings.Default.ComPort, SerialCommsSettings.Default.BaudRate, SerialCommsSettings.Default.DataBits, SerialCommsSettings.Default.Parity, SerialCommsSettings.Default.StopBits); break; case CommsMode.Tcp: channel = new TcpCommsChannel( TCPCommsSettings.Default.IP_Address, TCPCommsSettings.Default.Port); break; default: // Throw unknown comms channel exception. } return channel; } }

    Read the article

  • Use of properties vs backing-field inside owner class

    - by whatispunk
    I love auto-implemented properties in C# but lately there's been this elephant standing in my cubicle and I don't know what to do with him. If I use auto-implemented properties (hereafter "aip") then I no longer have a private backing field to use internally. This is fine because the aip has no side-effects. But what if later on I need to add some extra processing in the get or set? Now I need to create a backing-field so I can expand my getters and setters. This is fine for external code using the class, because they won't notice the difference. But now all of the internal references to the aip are going to invoke these side-effects when they access the property. Now all internal access to the once aip must be refactored to use the backing-field. So my question is, what do most of you do? Do you use auto-implemented properties or do you prefer to always use a backing-field? What do you think about properties with side-effects?

    Read the article

  • In Android GUI flickers when reading the properties file

    - by ManojValiveti
    Hi, I am getting the GUI flicker when reading a file properties and accordingly enabling/disabling checkbox and List value in listbox. when i remove this file reading code the GUI doesnt have flicker. I am reading the properties before creating the Preferences in OnCreate(). Attached the file write code below for reference.Please let us know is there any other way to read and update the preference staus. private void SetExtendConf(String key, String strValue) { mProperties = new Properties(); try { File file = new File(FILE_EXT); if(!file.exists()) file.createNewFile(); file.setWritable(true,false); FileInputStream fis = new FileInputStream(file); mProperties.load(fis); fis.close(); FileOutputStream stream = new FileOutputStream(file); Log.d(TAG, "Setting Values " + key + ":"+ strValue); mProperties.setProperty(key, strValue); mProperties.store(stream,"ext.conf"); stream.close(); } catch (IOException e) { Log.d(TAG, "Could not open properties file: " + GPS_FILE_EXT); } } -Manoj

    Read the article

  • How can I use "Dependency Injection" in simple php functions, and should I bother?

    - by Tchalvak
    I hear people talking about dependency injection and the benefit of it all the time, but I don't really understand it. I'm wondering if it's a solution to the "I pass database connections as arguments all the time" problem. I tried reading wikipedia's entry on it, but the example is written in Java so I don't solidly understand the difference it is trying to make clear. ( http://en.wikipedia.org/wiki/Dependency_injection ). I read this dependency-injection-in-php article ( http://www.potstuck.com/2009/01/08/php-dependency-injection/ ), and it seems like the objective is to not pass dependencies to an object directly, but to cordon off the creation of an object along with the creation of it's dependencies. I'm not sure how to apply that in a using php functions context, though. Additionally, is the following Dependency Injection, and should I bother trying to do dependency injection in a functional context? Version 1: (the kind of code that I create, but don't like, every day) function get_data_from_database($database_connection){ $data = $database_connection->query('blah'); return $data; } Version 2: (don't have to pass a database connection, but perhaps not dependency injection?) function get_database_connection(){ static $db_connection; if($db_connection){ return $db_connection; } else { // create db_connection ... } } function get_data_from_database(){ $conn = get_database_connection(); $data = $conn->query('blah'); return $data; } $data = get_data_from_database(); Version 3: (the creation of the "object"/data is separate, and the database code is still, so perhaps this would count as dependency injection?) function factory_of_data_set(){ static $db_connection; $data_set = null; $db_connection = get_database_connection(); $data_set = $db_connection->query('blah'); return $data_set; } $data = factory_of_data_set(); Anyone have a good resource or just insight that makes the method and benefit -crystal- clear?

    Read the article

  • Dependency Injection: Jetty 7

    - by Malax
    Hi StackOverflow! My application requires several interface implementations which require a Jetty server to do their job. This is, however, not necessarily the case in every implementations of those interfaces so the Jetty server is only a dependency. Since it would be a huge amount of pain to wrap the entire jetty server with all its logging, connector and Handler configurations, I want to inject the server to those implementations with Spring. I decided that injecting the Server class is not a good idea because an implementation could stop the server even if its required at another location. Currently I inject empty HandlerList classes to those implementations and they register their handlers to avoid those problems. The Problem: Those handlers might interfere with other handlers for example: implementation one might register a handler for /foo and implementation two too... problem. Has anyone used Jetty in such an environment? And how could this problem be solved? My XML to clarify my problem: <bean id="jetty" class="org.eclipse.jetty.server.Server" destroy-method="stop"> <property name="connectors"> <list> <bean class="org.eclipse.jetty.server.bio.SocketConnector"> <property name="host" value="10.8.0.46" /> <property name="port" value="9999" /> </bean> </list> </property> <property name="handler"> <bean class="org.eclipse.jetty.server.handler.HandlerCollection"> <property name="handlers"> <list> <ref bean="jetty.handlerList" /> <bean class="org.eclipse.jetty.server.handler.RequestLogHandler"> <property name="requestLog"> <bean class="org.eclipse.jetty.server.NCSARequestLog"> <constructor-arg value="${jetty.logfile}" /> <property name="extended" value="false"/> </bean> </property> </bean> </list> </property> </bean> </property> <property name="sendServerVersion" value="false" /> </bean> <bean id="jetty.handlerList" class="org.eclipse.jetty.server.handler.HandlerList" /> If I require an empty HandlerList I use something like this where com.example.myapp.util.ioc.CreateHandlerListFactory is a org.springframework.beans.factory.FactoryBean which creates a new HandlerList within the given HandlerList. <constructor-arg> <bean class="com.example.myapp.util.ioc.CreateHandlerListFactory"> <constructor-arg ref="jetty.handlerList"/> </bean> </constructor-arg>

    Read the article

  • Add properties to stdClass object from another object

    - by Florin
    I would like to be able to do the following: $obj = new stdClass; $obj->status = "success"; $obj2 = new stdClass; $obj2->message = "OK"; How can I extend $obj so that it contains the properties of $obj2, eg: $obj->status //"success" $obj->message // "OK" I know I could use an array, add all properties to the array and then cast that back to object, but is there a more elegant way, something like this: extend($obj, $obj2); //adds all properties from $obj2 to $obj Thanks!

    Read the article

  • Dependency property does not work within a geometry in a controltemplate

    - by Erik Bongers
    I have a DepencencyProperty (a boolean) that works fine on an Ellipse, but not on an ArcSegment. Am I doing something that is not possible? Here's part of the xaml. Both the TemplateBindings of Origin and LargeArc do not work in the geometry. But the LargeArc DependencyProperty does work in the Ellipse, so my DependencyProperty seems to be set up correctly. <ControlTemplate TargetType="{x:Type nodes:TestCircle}"> <Canvas Background="AliceBlue"> <Ellipse Height="10" Width="10" Fill="Yellow" Visibility="{TemplateBinding LargeArc, Converter={StaticResource BoolToVisConverter}}"/> <Path Canvas.Left="0" Canvas.Top="0" Stroke="Black" StrokeThickness="3"> <Path.Data> <GeometryGroup> <PathGeometry> <PathFigure IsClosed="True" StartPoint="{TemplateBinding Origin}"> <LineSegment Point="150,100" /> <ArcSegment Point="140,150" IsLargeArc="{TemplateBinding LargeArc}" Size="50,50" SweepDirection="Clockwise"/> </PathFigure> </PathGeometry> </GeometryGroup> </Path.Data> </Path> </Canvas> </ControlTemplate> What I'm trying to build is a (sort of) pie-shaped usercontrol where the shape of the Pie is defined by DependencyProperties and the actual graphics used are in a template, so they can be replaced or customized. In other words: I would like the code-behind to be visual-free (which, I assume, is good separation). SOLUTION--------------------------(I'm not allowed to answer my own questions yet) I found the answer myself, and this can be useful for others encountering the same issue. This is why the TemplateBinding on the Geometry failed: A TemplateBinding will only work when binding a DependencyProperty to another DependencyProperty. Following article set me on the right track: http://blogs.msdn.com/b/liviuc/archive/2009/12/14/wpf-templatebinding-vs-relativesource-templatedparent.aspx The ArcSegment properties are no DependencyProperties. Thus, the solution to the above problem is to replace <ArcSegment Point="140,150" IsLargeArc="{TemplateBinding LargeArc}" with <ArcSegment Point="140,150" IsLargeArc="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=LargeArc}" Colin, your working example where an 'ordinary' binding was used in the geometry set me on the right track. BTW, love the infographics and the construction of your UserControl in your blogpost. And, hey, that quick tip on code snippets, and especially on that DP attribute and the separation of those DPs into a partial class file is pure gold!

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >