hyperjaxb binding customization exclude package - binding

I have an A.xsd that import a Common.xsd (name space eg. "http://common.pack"), then I would to exclude the contribution (jsut jpa annotations) of Common.xsd to pack.common package but I need other xsd that have same namespace can stil contriute to pack.common package .
I am using this excerpt from my bindinds.xml :
<jaxb:bindings schemaLocation="CSG_Schemas\MultiMissionProtocol\MultiMissionCommon.xsd" node="/xs:schema" >
<jaxb:schemaBindings >
<jaxb:package name="pack.com package"/>
</jaxb:schemaBindings>
<hj:ignored-package name="pack.com package"/>
</jaxb:bindings>
but when run maven , it seems xjc delete the pack.common completely ,instead I want to block only entities coming from common.xsd
when I am wrong ?

Related

Separate logging using LOG4J2

I have a requirement to maintain separate logging files EAR1.log and EAR2.log for 2 Java EE applications EAR1 and EAR2 respectively using LOG4J2 v2.1. Going through the internet, I could see help specific to LOG4J v1.x, but couldn’t find any for LOG4J2.
EAR1 (need to use “EAR1-log4j2.xml”):
1. Web project “web1”
2. EJB project “ejb1”
3. Java project “java1”
4. Java project “java2”
5. Java project “java3”
EAR2 (need to use “EAR2-log4j2.xml”):
1. Web project “web2”
2. EJB project “ejb2”
3. Java project “java1” (same as above)
4. Java project “java2” (same as above)
5. Java project “java3” (same as above)
http://logging.apache.org/log4j/2.x/manual/migration.html
http://logging.apache.org/log4j/2.x/manual/logsep.html
what is working now:
my log4j2.xml is placed in ApplicationServer classpath & a single log is successfully getting written for both the EAR’s
my completed attempts to maintain separate log files for both EAR’s:
• Modifying web.xml only applies the logging change to the web project alone
• I tried the following code, but this applies only to current class
LoggerContext loggerCtx = Configurator.initialize("mrpst", null, PathOfMyLog4j2XmlPath );
Logger log = loggerCtx.getLogger("MyClassName");
I’m trying to check if it is possible to complete this requirement by editing log4j2.xml alone(without code change). Appreciate if a documentation link can be provided or any alternate approach.
My suggestion is to inject context into your log event and filter on that context using a logger route, which directs to an appropriate appender.
At the point of logging:
String routeKey = SOME_FIELD_THAT_IDENTIFIES_CONTAINER;
ThreadContext.put( "myEARroute", routeKey );
In your log4j2.xml config:
<Routing name="myEARroute">
<Routes pattern="$${ctx:myEARroute}">
<!-- if you forget to inject context, the routing key will be empty -->
<Route
key="$${ctx:myEARroute}"
ref="STDOUT" />
<Route
key="EAR1"
ref="myEAR1Appender" />
<Route
key="EAR2"
ref="myEAR2Appender" />
</Routes>
</Routing>
Now you just have to create appenders matching your appender names:
<RollingRandomAccessFile
name="myEAR1Appender"
filename="logs/Ear1.log"
<!-- fill in the rest of your appender config, as desired -->
</RollingRandomAccessFile>
repeat for other appenders.

How to implement a Groovy global AST transformation in a Grails plugin?

I'd like to modify some of my Grails domain classes at compilation time. I initially thought this was a job for Groovy's global ASTTransformation since I don't want to annotate my domain classes (which local transformers require). What's the best way to do this?
I also tried mimicking DefaultGrailsDomainClassInjector.java by creating my own class in the same package, implementing the same interfaces, but I probably just didn't know how to package it up in the right place because I never saw my methods get invoked.
On the other hand I was able to manually create a JAR which contained a compiled AST transformation class, along with the META-INF/services artifacts that plain Groovy global transformations require. I threw that JAR into my project's "lib" dir and visit() was successfully invoked. Obviously this was a sloppy job because I am hoping to have the source code of my AST transformation in a Grails plugin and not require a separate JAR artifact if I don't have to, plus I couldn't get this approach to work by having the JAR in my Grails plugin's "lib" but had to put it into the Grails app's "lib" instead.
This post helped a bit too: Grails 2.1.1 - How to develop a plugin with an AstTransformer?
The thing about global transforms the transform code should be available when the compilation starts. Having the transformer in a jar was what i did first! But as you said it is a sloppy job.
What you want to do is have your ast transforming class compile before others gets to the compilation phase. Here is what you do!
Preparing the transformer
Create a directory called precompiled in src folder! and add the Transformation class and the classes (such as annotations) the transformer uses in this directory with the correct packaging structure.
Then create a file called org.codehaus.groovy.transform.ASTTransformation in called precompiled/META-INF/services and you will have the following structure.
precompiled
--amanu
----LoggingASTTransformation.groovy
--META-INF
----services
------org.codehaus.groovy.transform.ASTTransformation
Then write the fully qualified name of the transformer in the org.codehaus.groovy.transform.ASTTransformation file, for the example above the fully qualified name would be amanu.LoggingASTTransformation
Implementation
package amanu
import org.codehaus.groovy.transform.GroovyASTTransformation
import org.codehaus.groovy.transform.ASTTransformation
import org.codehaus.groovy.control.CompilePhase
import org.codehaus.groovy.ast.ASTNode
import org.codehaus.groovy.control.SourceUnit
#GroovyASTTransformation(phase=CompilePhase.CANONICALIZATION)
class TeamDomainASTTransformation implements ASTTransformation{
public void visit(ASTNode[] nodes, SourceUnit sourceUnit) {
println ("*********************** VISIT ************")
source.getAST()?.getClasses()?.each { classNode ->
//Class node is a class that is contained in the file being compiled
classNode.addProperty("filed", ClassNode.ACC_PUBLIC, new ClassNode(Class.forName("java.lang.String")), null, null, null)
}
}
}
Compilation
After implementing this you can go off in two ways! The first approach is to put it in a jar, like you did! and the other is to use a groovy script to compile it before others. To do this in grails, we use _Events.groovy script.
You can do this from a plugin or the main project, it doesn't matter. If it doesn't exist create a file called _Events.groovy and add the following content.
The code is copied from reinhard-seiler.blogspot.com with modifications
eventCompileStart = {target ->
...
compileAST(pluginBasedir, classesDirPath)
...
}
def compileAST(def srcBaseDir, def destDir) {
ant.sequential {
echo "Precompiling AST Transformations ..."
echo "src ${srcBaseDir} ${destDir}"
path id: "grails.compile.classpath", compileClasspath
def classpathId = "grails.compile.classpath"
mkdir dir: destDir
groovyc(destdir: destDir,
srcDir: "$srcBaseDir/src/precompiled",
classpathref: classpathId,
stacktrace: "yes",
encoding: "UTF-8")
copy(toDir:"$destDir/META-INF"){
fileset(dir:"$srcBaseDir/src/precompiled/META-INF")
}
echo "done precompiling AST Transformations"
}
}
the previous script will compile the transformer before others are compiled! This enable the transformer to be available for transforming your domain classes.
Don't forget
If you use any class other than those added in your classpath, you will have to precompile those too. The above script will compile everything in the precompiled directory and you can also add classes that don't need ast, but are needed for it in that directory!
If you want to use domain classes in transformation, You might want to do the precompilation in evenCompileEnd block! But this will make things slower!
Update
#Douglas Mendes mentioned there is a simple way to cause pre compilation. Which is more concise.
eventCompileStart = {
target -> projectCompiler.srcDirectories.add(0, "./src/precompiled")
}

Importing external domain classes into Grails

I'm trying to create a sample project where domain classes are in an external normal groovy project and then used in a grails app (see https://github.com/ivanarrizabalaga/grails-domain-griffon):
book-svr
book-common
I'm also following the grails guide in order to get this (see http://grails.org/doc/latest/guide/hibernate.html) but the imported classes are not being recognized as domain classes.
The relevant parts:
External domain class:
package com.nortia.book
import grails.persistence.Entity
#Entity
class Book implements Serializable{
private static final long serialVersionUID = 1L;
String title
String author
static constraints = {
title blank:false
author blank:false
}
}
build.gradle:
....
dependencies {
// We use the latest groovy 2.x version for building this library
compile 'org.codehaus.groovy:groovy:2.1.7'
compile "org.grails:grails-datastore-gorm-hibernate4:3.0.0.RELEASE"
compile "org.grails:grails-spring:2.3.7"
....
In the grails app,
hibernate.cfg.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
'-//Hibernate/Hibernate Configuration DTD 3.0//EN'
'http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd'>
<hibernate-configuration>
<session-factory>
<mapping package='com.nortia.book' />
<mapping class='com.nortia.book.Book' />
</session-factory>
</hibernate-configuration>
BookController.groovy (I've tried an scaffolded and coded controller, and both failed):
...
class BookController{
static scaffold=Book
}
...
console.log (error):
ERROR ScaffoldingGrailsPlugin - Cannot generate controller logic for scaffolded class class com.nortia.book.Book. It is not a domain class!
Finally, suspicious log messages while initializing:
DEBUG cfg.Configuration - session-factory config [null] named package [com.nortia.book] for mapping
INFO cfg.Configuration - Mapping package com.nortia.book
WARN cfg.AnnotationBinder - Package not found or wo package-info.java: com.nortia.book
DEBUG cfg.Configuration - session-factory config [null] named class [com.nortia.book.Book] for mapping
INFO cfg.Configuration - Configured SessionFactory: null
So I'm wondering:
What's the missing piece?
According to the docs, looks like external 'domains' must be java classes but that's not a good option for my purpose.
I haven't try yet with a grails binary plugin instead of a groovy project, is it the way to go? (I need to use the domains in a griffon project that is why I opted this way first).
Finally solve it creating a 'sort of' a binary plugin manually.
Let's take a look step by step:
book-domain
Tree structure
src
main
groovy
demo
Book.groovy
resources
META-INF
grails-plugin.xml
build.gradle
Book.groovy
package demo
import grails.persistence.Entity
#Entity
class Book{
String title
static constraints = {
title blank: false
}
}
grails-plugin.xml
<plugin name='book-domain' version='1.0' grailsVersion='2.3 > *'>
<author>Ivan Arrizabalaga</author>
<title>External domains</title>
<description>An external domain plugin</description>
<documentation>http://grails.org/plugin/book-domain</documentation>
<type>demo.BookDomainGrailsPlugin</type>
<packaging>binary</packaging>
<resources>
<resource>demo.Book</resource>
</resources>
</plugin>
build.gradle
/*
* This build file was auto generated by running the Gradle 'init' task
* by 'arrizabalaga' at '5/26/14 12:34 PM' with Gradle 1.11
*
* This generated file contains a sample Groovy project to get you started.
* For more details take a look at the Groovy Quickstart chapter in the Gradle
* user guide available at http://gradle.org/docs/1.11/userguide/tutorial_groovy_projects.html
*/
// Apply the groovy plugin to add support for Groovy
apply plugin: 'groovy'
apply plugin: 'maven'
group = 'demo'
version = '1.0'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'maven central' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
mavenLocal()
}
// In this section you declare the dependencies for your production and test code
dependencies {
// We use the latest groovy 2.x version for building this library
compile 'org.codehaus.groovy:groovy-all:2.1.9'
//compile "org.grails:grails-datastore-gorm-hibernate4:3.1.0.RELEASE"
compile "org.grails:grails-datastore-gorm-hibernate:3.1.0.RELEASE"
compile "commons-lang:commons-lang:2.6"
// We use the awesome Spock testing and specification framework
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile 'junit:junit:4.11'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
using it
Now the project can be built (gradle install to publish it into your local maven repo) and used (declaring the proper dependency) in any given project.
If the project that uses the jar is a Grails app it turns automatically the #Entity classes into real Domains.
Hope it helps.

Replacing XmlType.namespace using jaxb bindings during type generation

My web-services application is moving from Axis to JAX-WS and I'm having trouble doing some of the conversions. My primary issue is that I have several XSD's with the same types defined slightly differently, but with the same names. During my wsimport I'm able to use an external JAXB bindings file to resolve the packages, but the generated classes still end up with the same #XmlType annotations.
V1:
package com.service.v1.bill.request;
#XmlType(name = "FileBillReqType", namespace = "http://epayments.metavante.com/types/bill/request"})
public class FileBillReqType extends AbstractContextMethodRequest...
V2:
package com.service.v2.bill.request;
#XmlType(name = "FileBillReqType", namespace = "http://epayments.metavante.com/types/bill/request"})
public class FileBillReqType extends AbstractContextMethodRequest...
Binding:
<jaxb:bindings schemaLocation="file:../wsdl/v1/bill/BillRequest.xsd"
node="/xs:schema[#targetNamespace='http://service.example.com/bill/request']">
<jaxb:schemaBindings>
<jaxb:package name="com.service.v1.bill.request" />
</jaxb:schemaBindings>
</jaxb:bindings>
Previously this would have been resolved with the type mappings provided by axis (which we hard coded into a massively ugly wsdd):
<service name="v1" provider="java:RPC" style="document" use="literal">...
<typeMapping
xmlns:ns="http://service.example.com/bill/request"
qname="ns:FileBillReqType"
type="java:com.service.v1.bill.request.FileBillReqType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>...
Is there anyway to get my generated JAXB objects to have a custom namespace without modifying the generated files manually every time I regenerate them (there are hundreds)?
Specifying another xjb customization with v2 as schema location while generating the client classes using wsimport might solve the problem.
<jaxb:bindings schemaLocation="file:../wsdl/v2/bill/BillRequest.xsd"
node="/xs:schema[#targetNamespace='http://service.example.com/bill/request']">
<jaxb:schemaBindings>
<jaxb:package name="com.service.v2.bill.request" />
</jaxb:schemaBindings>
</jaxb:bindings>

What are the MSBuild project level properties for Delphi?

The Delphi documentation for MSBuild says
/property:name=value sets or overrides
project-level properties, where name
is the property name and value is the
property value. Use a semicolon or a
comma to separate multiple properties,
or specify each property separately.
/p is also acceptable. For example:
/property:WarningLevel=2;OutputDir=bin\Debug
I can't find a list of available properties, here's what I know so far:
WarningLevel
OutputDir (dcc32 -e equivalent)
Config
I'd like to get a complete list, but I'm most interested in being able to override the Defines (dcc32 -d equivalent). And if these can be lined up against dcc32 equivalents that'd be icing!
You can find most of the parameters in the msbuild script C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Borland.Delphi.Targets when you look at the CoreCompile target.
ExeOutput="$(DCC_ExeOutput)"
BplOutput="$(DCC_BplOutput)"
DcuOutput="$(DCC_DcuOutput)"
DcpOutput="$(DCC_DcpOutput)"
HppOutput="$(DCC_HppOutput)"
ObjOutput="$(DCC_ObjOutput)"
BpiOutput="$(DCC_BpiOutput)"
DependencyCheckOutputName = "$(DCC_DependencyCheckOutputName)"
UnitSearchPath="$(UnitSearchPath)"
ResourcePath="$(ResourcePath)"
IncludePath="$(IncludePath)"
ObjPath="$(_ObjectPath)"
UnitAlias="$(DCC_UnitAlias)"
ConsoleTarget="$(DCC_ConsoleTarget)"
Define="$(DCC_Define)"
FindError="$(DCC_FindError)"
MapFile="$(DCC_MapFile)"
Hints="$(DCC_Hints)"
CBuilderOutput="$(DCC_CBuilderOutput)"
BaseAddress="$(DCC_BaseAddress)"
UsePackage="$(_UsePackage)"
MakeModifiedUnits="$(DCC_MakeModifiedUnits)"
BuildAllUnits="$(DCC_BuildAllUnits)"
NameSpace="$(NameSpace)"
OldDosFileNames="$(DCC_OldDosFileNames)"
Quiet="$(DCC_Quiet)"
DebugInfoInExe="$(DCC_DebugInfoInExe)"
DebugVN="$(DCC_DebugVN)"
RemoteDebug="$(DCC_RemoteDebug)"
OutputNeverBuildDcps="$(DCC_OutputNeverBuildDcps)"
NoConfig="true"
OutputDRCFile="$(DCC_OutputDRCFile)"
OutputDependencies="$(DCC_OutputDependencies)"
OutputXMLDocumentation="$(DCC_OutputXMLDocumentation)"
DefaultNamespace="$(DCC_DefaultNamespace)"
Platform="$(DCC_Platform)"
UnsafeCode="$(DCC_UnsafeCode)"
Warnings="$(DCC_Warnings)"
Alignment="$(DCC_Alignment)"
MinimumEnumSize="$(DCC_MinimumEnumSize)"
FullBooleanEvaluations="$(DCC_FullBooleanEvaluations)"
AssertionsAtRuntime="$(DCC_AssertionsAtRuntime)"
DebugInformation="$(DCC_DebugInformation)"
ImportedDataReferences="$(DCC_ImportedDataReferences)"
LongStrings="$(DCC_LongStrings)"
IOChecking="$(DCC_IOChecking)"
WriteableConstants="$(DCC_WriteableConstants)"
LocalDebugSymbols="$(DCC_LocalDebugSymbols)"
RunTimeTypeInfo="$(DCC_RunTimeTypeInfo)"
Optimize="$(DCC_Optimize)"
OpenStringParams="$(DCC_OpenStringParams)"
IntegerOverflowCheck="$(DCC_IntegerOverflowCheck)"
RangeChecking="$(DCC_RangeChecking)"
TypedAtParameter="$(DCC_TypedAtParameter)"
PentiumSafeDivide="$(DCC_PentiumSafeDivide)"
StrictVarStrings="$(DCC_StrictVarStrings)"
GenerateStackFrames="$(DCC_GenerateStackFrames)"
ExtendedSyntax="$(DCC_ExtendedSyntax)"
SymbolReferenceInfo="$(DCC_SymbolReferenceInfo)"
StackSize="$(DCC_StackSize)"
ImageBase="$(DCC_ImageBase)"
Description="$(DCC_Description)"
DelaySign="$(DCC_DelaySign)"
KeyFile="$(DCC_KeyFile)"
KeyContainer="$(DCC_KetContainer)"
CodePage="$(DCC_CodePage)"
SYMBOL_DEPRECATED="$(DCC_SYMBOL_DEPRECATED)"
SYMBOL_LIBRARY="$(DCC_SYMBOL_LIBRARY)"
SYMBOL_PLATFORM="$(DCC_SYMBOL_PLATFORM)"
SYMBOL_EXPERIMENTAL="$(DCC_SYMBOL_EXPERIMENTAL)"
UNIT_LIBRARY="$(DCC_UNIT_LIBRARY)"
UNIT_PLATFORM="$(DCC_UNIT_PLATFORM)"
UNIT_DEPRECATED="$(DCC_UNIT_DEPRECATED)"
UNIT_EXPERIMENTAL="$(DCC_UNIT_EXPERIMENTAL)"
HRESULT_COMPAT="$(DCC_HRESULT_COMPAT)"
HIDING_MEMBER="$(DCC_HIDING_MEMBER)"
HIDDEN_VIRTUAL="$(DCC_HIDDEN_VIRTUAL)"
GARBAGE="$(DCC_GARBAGE)"
BOUNDS_ERROR="$(DCC_BOUNDS_ERROR)"
ZERO_NIL_COMPAT="$(DCC_ZERO_NIL_COMPAT)"
STRING_CONST_TRUNCED="$(DCC_STRING_CONST_TRUNCED)"
FOR_LOOP_VAR_VARPAR="$(DCC_FOR_LOOP_VAR_VARPAR)"
TYPED_CONST_VARPAR="$(DCC_TYPED_CONST_VARPAR)"
ASG_TO_TYPED_CONST="$(DCC_ASG_TO_TYPED_CONST)"
CASE_LABEL_RANGE="$(DCC_CASE_LABEL_RANGE)"
FOR_VARIABLE="$(DCC_FOR_VARIABLE)"
CONSTRUCTING_ABSTRACT="$(DCC_CONSTRUCTING_ABSTRACT)"
COMPARISON_FALSE="$(DCC_COMPARISON_FALSE)"
COMPARISON_TRUE="$(DCC_COMPARISON_TRUE)"
COMPARING_SIGNED_UNSIGNED="$(DCC_COMPARING_SIGNED_UNSIGNED)"
COMBINING_SIGNED_UNSIGNED="$(DCC_COMBINING_SIGNED_UNSIGNED)"
UNSUPPORTED_CONSTRUCT="$(DCC_UNSUPPORTED_CONSTRUCT)"
FILE_OPEN="$(DCC_FILE_OPEN)"
FILE_OPEN_UNITSRC="$(DCC_FILE_OPEN_UNITSRC)"
BAD_GLOBAL_SYMBOL="$(DCC_BAD_GLOBAL_SYMBOL)"
DUPLICATE_CTOR_DTOR="$(DCC_DUPLICATE_CTOR_DTOR)"
INVALID_DIRECTIVE="$(DCC_INVALID_DIRECTIVE)"
PACKAGE_NO_LINK="$(DCC_PACKAGE_NO_LINK)"
PACKAGED_THREADVAR="$(DCC_PACKAGED_THREADVAR)"
IMPLICIT_IMPORT="$(DCC_IMPLICIT_IMPORT)"
HPPEMIT_IGNORED="$(DCC_HPPEMIT_IGNORED)"
NO_RETVAL="$(DCC_NO_RETVAL)"
USE_BEFORE_DEF="$(DCC_USE_BEFORE_DEF)"
FOR_LOOP_VAR_UNDEF="$(DCC_FOR_LOOP_VAR_UNDEF)"
UNIT_NAME_MISMATCH="$(DCC_UNIT_NAME_MISMATCH)"
NO_CFG_FILE_FOUND="$(DCC_NO_CFG_FILE_FOUND)"
IMPLICIT_VARIANTS="$(DCC_IMPLICIT_VARIANTS)"
UNICODE_TO_LOCALE="$(DCC_UNICODE_TO_LOCALE)"
LOCALE_TO_UNICODE="$(DCC_LOCALE_TO_UNICODE)"
IMAGEBASE_MULTIPLE="$(DCC_IMAGEBASE_MULTIPLE)"
SUSPICIOUS_TYPECAST="$(DCC_SUSPICIOUS_TYPECAST)"
PRIVATE_PROPACCESSOR="$(DCC_PRIVATE_PROPACCESSOR)"
UNSAFE_TYPE="$(DCC_UNSAFE_TYPE)"
UNSAFE_CODE="$(DCC_UNSAFE_CODE)"
UNSAFE_CAST="$(DCC_UNSAFE_CAST)"
OPTION_TRUNCATED="$(DCC_OPTION_TRUNCATED)"
WIDECHAR_REDUCED="$(DCC_WIDECHAR_REDUCED)"
DUPLICATES_IGNORED="$(DCC_DUPLICATES_IGNORED)"
UNIT_INIT_SEQ="$(DCC_UNIT_INIT_SEQ)"
LOCAL_PINVOKE="$(DCC_LOCAL_PINVOKE)"
MESSAGE_DIRECTIVE="$(DCC_MESSAGE_DIRECTIVE)"
TYPEINFO_IMPLICITLY_ADDED="$(DCC_TYPEINFO_IMPLICITLY_ADDED)"
XML_WHITESPACE_NOT_ALLOWED="$(DCC_XML_WHITESPACE_NOT_ALLOWED)"
XML_UNKNOWN_ENTITY="$(DCC_XML_UNKNOWN_ENTITY)"
XML_INVALID_NAME_START="$(DCC_XML_INVALID_NAME_START)"
XML_INVALID_NAME="$(DCC_XML_INVALID_NAME)"
XML_EXPECTED_CHARACTER="$(DCC_XML_EXPECTED_CHARACTER)"
XML_CREF_NO_RESOLVE="$(DCC_XML_CREF_NO_RESOLVE)"
XML_NO_PARM="$(DCC_XML_NO_PARM)"
XML_NO_MATCHING_PARM="$(DCC_XML_NO_MATCHING_PARM)"
So to set the defines you could use the DCC_Define parameter like this:
msbuild yourproject.dproj /p:DCC_Define=MY_DEFINE
Others you will find in the .dproj file of your project
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
So it is Configuration and not Config. At least in Delphi 2007.
You might want to learn more about msbuild in general to understand the scripts better and learn how you could make your own msbuild scripts to drive a build machine.
Disclaimer: This information is from a Delphi 2007 setup

Resources